package org.linlinjava.litemall.db.dao;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.linlinjava.litemall.db.domain.LitemallSeat;
import org.linlinjava.litemall.db.domain.LitemallStore;
import org.linlinjava.litemall.db.domain.SeatVo;
import org.linlinjava.litemall.db.domain.StoreCategoryVo;

import java.util.List;

public interface StoreMapper {

    List<StoreCategoryVo> selectCategoryVoList(Integer storeId);

    @Update("update litemall_store set   balance = balance + #{money} where id =#{storeId}")
    long plusBalance(@Param("storeId")Integer storeId, @Param("money")Long money);

    @Update("update litemall_store set   balance = balance - #{money},frozen = frozen+ #{money} where id =#{storeId} and balance>=#{money} ")
    long updateBalance(@Param("storeId")Integer storeId, @Param("money")Long money);

    @Update("update litemall_store set   frozen = #{frozen} where id = #{storeId} ")
    void updateFrozen(@Param("frozen")Long frozen,@Param("storeId")Integer storeId);

    @Update("update litemall_store set balance = balance + frozen,  frozen = 0 where id =#{storeId} ")
    void freeFrozen(@Param("storeId")Integer storeId);

    List<LitemallStore> selectByTag(@Param("tag")String tag, @Param("keyword") String keyword, @Param("page") Integer page, @Param("size") Integer size, @Param("sort") String sort, @Param("order") String order);

    List<LitemallSeat> selectSeatIdList(@Param("storeId")Integer storeId, @Param("type")String type, @Param("orderRange")Integer orderRange);

    List<SeatVo> selectAllSeatList(@Param("storeId")Integer storeId, @Param("type")String type, @Param("orderRange")Integer orderRange);
}
